package com.woniuxy.services.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniuxy.daos.LostDao;
import com.woniuxy.entitys.Lost;
import com.woniuxy.services.LostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class LostServiceImpl implements LostService {
    @Autowired
    private LostDao lostDao;

    @Override
    public PageInfo<Lost> selectAll(Integer currentPage, Integer pageSize) {
        PageHelper.startPage(currentPage,pageSize);
        List<Lost> l=lostDao.selectAll();
        PageInfo<Lost> pageInfo = new PageInfo(l);  //所有信息都封装在这个pageInfo里
        return pageInfo;
    }




    @Override
    public PageInfo<Lost> selectByCnameOrStatus(Integer currentPage, Integer pageSize, Integer lost_status, String com_name, String user_name) {
        PageHelper.startPage(currentPage,pageSize);
        List<Lost> ll= lostDao.selectByCnameOrStatus(lost_status,com_name,user_name);
        PageInfo<Lost> pageInfo = new PageInfo(ll);
        return pageInfo;

    }




    @Override
    public Lost selectById(Integer lost_id) {
        return lostDao.selectByPrimaryKey(lost_id);
    }


    @Override
    public int updateByPrimaryKeySelective(Lost record) {
        return lostDao.updateByPrimaryKeySelective(record);
    }

    //客户流失折线图（按年份查询）
    @Override
    public List<Map<String, Integer>> getLostCount(Integer year) {
        return lostDao.getLostCount(year);
    }

    //按照客户经理或公司名称查询流失记录
    @Override
    public List<Lost> getLostByCidOrUid(Integer user_id, Integer com_id) {
        return lostDao.getLostByCidOrUid(user_id,com_id);
    }


}
